Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redhat_subscription: refactor of internal Rhsm class #6658

Conversation

ptoscano
Copy link
Contributor

@ptoscano ptoscano commented Jun 9, 2023

SUMMARY

The two RegistrationBase & Rhsm classes were copied from the ones in the shared module_utils.redhat module; that said:

  • the versions here got improvements over the years
  • the RegistrationBase in module_utils.redhat is used only by the RHN modules, which are deprecated and slated for removal

Hence, the classes here can be kept and simplified a bit:

  • fold the non-dummy content of RegistrationBase into Rhsm: there is no more need for the separate RegistrationBase base class
  • drop the init arguments username, password, and token: the instance variables of them are not used anywhere, as the needed credentials (together with other variables) are passed to the register() method
  • create the Rhsm object later in main(), after the AnsibleModule creation and the uid check: this avoids the creation of Rhsm with a null module variable, changing it later

There should be no behaviour change.

ISSUE TYPE
  • Refactoring Pull Request
COMPONENT NAME

redhat_subscription

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added module module plugins plugin (any type) redhat_subscription tests tests unit tests/unit labels Jun 9, 2023
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-7 labels Jun 10, 2023
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you add a changelog fragment (minor_changes, just mention that some internal refactoring happened)?

@ptoscano
Copy link
Contributor Author

Can you add a changelog fragment (minor_changes, just mention that some internal refactoring happened)?

Not to minimize the recommendation: would it be really something needs to be aware by reading release notes?

@felixfontein
Copy link
Collaborator

We have the general rule of always having a changelog fragment for any code change that affects plugins/ (that's not purely documentation or otherwise obviously not changing behavior, like changing comments). While it usually doesn't help users, it is useful to see all possibly relevant changes there were when trying to figure out why a task stopped working between two different versions of the collection.

The two RegistrationBase & Rhsm classes were copied from the ones in the
shared module_utils.redhat module; that said:
- the versions here got improvements over the years
- the RegistrationBase in module_utils.redhat is used only by the RHN
  modules, which are deprecated and slated for removal

Hence, the classes here can be kept and simplified a bit:
- fold the non-dummy content of RegistrationBase into Rhsm: there is no
  more need for the separate RegistrationBase base class
- drop the init arguments "username", "password", and "token": the
  instance variables of them are not used anywhere, as the needed
  credentials (together with other variables) are passed to the
  register() method
- create the Rhsm object later in main(), after the AnsibleModule
  creation and the uid check: this avoids the creation of Rhsm with a
  null module variable, changing it later

There should be no behaviour change.
@ptoscano ptoscano force-pushed the redhat_subscription-rhsm-refactor branch from 2d81aec to deebdb8 Compare June 10, 2023 11:41
@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jun 10, 2023
@felixfontein felixfontein merged commit 42f7531 into ansible-collections:main Jun 10, 2023
@patchback
Copy link

patchback bot commented Jun 10, 2023

Backport to stable-7: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-7/42f7531f212c6401ca351de62bde0369916d8e58/pr-6658

Backported as #6667

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein
Copy link
Collaborator

@ptoscano thanks!

patchback bot pushed a commit that referenced this pull request Jun 10, 2023
The two RegistrationBase & Rhsm classes were copied from the ones in the
shared module_utils.redhat module; that said:
- the versions here got improvements over the years
- the RegistrationBase in module_utils.redhat is used only by the RHN
  modules, which are deprecated and slated for removal

Hence, the classes here can be kept and simplified a bit:
- fold the non-dummy content of RegistrationBase into Rhsm: there is no
  more need for the separate RegistrationBase base class
- drop the init arguments "username", "password", and "token": the
  instance variables of them are not used anywhere, as the needed
  credentials (together with other variables) are passed to the
  register() method
- create the Rhsm object later in main(), after the AnsibleModule
  creation and the uid check: this avoids the creation of Rhsm with a
  null module variable, changing it later

There should be no behaviour change.

(cherry picked from commit 42f7531)
@ptoscano ptoscano deleted the redhat_subscription-rhsm-refactor branch June 10, 2023 13:45
felixfontein pushed a commit that referenced this pull request Jun 10, 2023
…of internal Rhsm class (#6667)

redhat_subscription: refactor of internal Rhsm class (#6658)

The two RegistrationBase & Rhsm classes were copied from the ones in the
shared module_utils.redhat module; that said:
- the versions here got improvements over the years
- the RegistrationBase in module_utils.redhat is used only by the RHN
  modules, which are deprecated and slated for removal

Hence, the classes here can be kept and simplified a bit:
- fold the non-dummy content of RegistrationBase into Rhsm: there is no
  more need for the separate RegistrationBase base class
- drop the init arguments "username", "password", and "token": the
  instance variables of them are not used anywhere, as the needed
  credentials (together with other variables) are passed to the
  register() method
- create the Rhsm object later in main(), after the AnsibleModule
  creation and the uid check: this avoids the creation of Rhsm with a
  null module variable, changing it later

There should be no behaviour change.

(cherry picked from commit 42f7531)

Co-authored-by: Pino Toscano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module module plugins plugin (any type) redhat_subscription tests tests unit tests/unit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants